const mongoose = require("mongoose");
const { mongopath } = require("../config/config.default");
const main = async () => {
  await mongoose.connect(mongopath);
};

main()
  .then((res) => {
    console.log("mongodb连接成功~");
  })
  .catch((err) => {
    console.log("mongodb连接失败~");
  });

// require返回的是一个对象
module.exports = {
  User: mongoose.model("User", require("./userModel")), //定义用户模型
  Video:mongoose.model("Video", require("./videoModel")), //定义视频模型
  Subscribe:mongoose.model("Subscribe", require("./subscribeModel")),//关注者和被关注者模型
  Videocomment:mongoose.model("Videocomment", require("./videocommentModel")),//关注者和被关注者模型
  Videolike:mongoose.model("Videolike", require("./videolikeModel")),//关注者和被关注者模型
  Collect:mongoose.model("Collect", require("./collectModel")),// 收藏视频 数据模型
};
